package com.yixin.mapper;

import com.yixin.entity.Role;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RoleMapper {
    @Insert("insert into role(role_key, role_name, description, is_del, create_time, update_time) values(#{roleKey}, #{roleName}, #{description}, #{isDel}, #{createTime}, #{updateTime})")
    void add(Role role);

    @Update("update role set role_key = #{roleKey}, role_name = #{roleName}, description = #{description}, update_time = #{updateTime} where id = #{id}")
    void update(Role role);

    @Update("update role set is_del = 1 where id = #{id}")
    void deleteById(Integer id);

    @Select("select id, role_key, role_name, description, is_del, create_time, update_time from role where is_del = 0 order by id")
    List<Role> findAll();
}
